package com.fs.iot.bean.query;

import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;

import java.time.LocalDateTime;
import java.time.ZoneOffset;

/**
 * 历史数据查询对象 
 * @author Coder Generator 2025-03-22 20:51:27 
 **/
@Data
public class DeviceHistoryDataQuery {
    @NotEmpty
    private String deviceCode;

    private String paramCode;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime beginTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endTime;

    public Long getBeginTimestamp() {
        if (null == beginTime) {
            return null;
        }

        return beginTime.toInstant(ZoneOffset.ofHours(8)).toEpochMilli();
    }

    public Long getEndTimestamp() {
        if (null == endTime) {
            return null;
        }

        return endTime.toInstant(ZoneOffset.ofHours(8)).toEpochMilli();
    }
}